package com.atguigu.gulimall.order.controller;

import com.atguigu.gulimall.order.entity.OrderEntity;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class RabbitSendController {
    @Autowired
    RabbitTemplate rabbitTemplate;

    @GetMapping("/sendmq")
    public String send(Integer num){
        for (int i = 0; i < num; i++) {
            if (i%2==0){
                OrderEntity orderEntity = new OrderEntity();
                orderEntity.setId((long) i);
                rabbitTemplate.convertAndSend("javaTest","java.test",orderEntity);
            }else {
//                OrderItemEntity orderItemEntity = new OrderItemEntity();
//                orderItemEntity.setId((long) i);
//                rabbitTemplate.convertAndSend("javaTest","java.test",orderItemEntity);
            }

        }
        return "ok";
    }
}
